"use strict";
cc._RF.push(module, '37533lXYi5FDbAkQSGbuiad', 'level_bunchAnimalGroup');
// scripts/levelBundles/level_bunchbunch/level_bunchAnimalGroup.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var level_bunchAnimalGroup = /** @class */ (function (_super) {
    __extends(level_bunchAnimalGroup, _super);
    function level_bunchAnimalGroup() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.showNode = null;
        _this.hintNode = null;
        _this.hintLb = null;
        _this.groupTag = -1;
        _this.level = null;
        _this.maxCount = 0;
        _this.animalAry = [];
        _this.closeDoorFlag = false;
        _this.lb = null;
        return _this;
    }
    level_bunchAnimalGroup.prototype.bindTag = function (level, tag) {
        this.level = level;
        this.groupTag = tag;
        this.lb.string = (tag + 1).toString();
    };
    level_bunchAnimalGroup.prototype.setMaxCount = function (maxCount) {
        this.maxCount = maxCount;
        this.showNode.height = 55 + 80 * maxCount;
        this.hintNode.height = 55 + 80 * maxCount;
        this.hintNode.active = false;
        this.hintLb.node.height = 80 * maxCount;
    };
    level_bunchAnimalGroup.prototype.start = function () {
    };
    level_bunchAnimalGroup.prototype.getLastTypeAnimal = function () {
        return this.animalAry[this.animalAry.length - 1];
    };
    /**
     * 判断是否可以加入动物
     */
    level_bunchAnimalGroup.prototype.checkCanAddAnimal = function (animal) {
        if (this.animalAry.length >= this.maxCount) {
            // O1HD.getModules().uiControlModule.showMessageBox("已满");
            return false;
        }
        var last = this.getLastTypeAnimal();
        if (!last) {
            return true;
        }
        return last.animalType == animal.animalType;
    };
    level_bunchAnimalGroup.prototype.spliceAnimal = function (animal) {
        var index = this.checkIndexByAnimal(animal);
        if (index > -1) {
            this.animalAry.splice(index, 1);
        }
    };
    level_bunchAnimalGroup.prototype.checkIndexByAnimal = function (animal) {
        return this.animalAry.findIndex(function (item) { return item.uuid == animal.uuid; });
    };
    level_bunchAnimalGroup.prototype.addAnimal = function (animal) {
        this.animalAry.push(animal);
        animal.node.zIndex = this.maxCount - this.animalAry.length;
    };
    level_bunchAnimalGroup.prototype.checkGroupIsVaild = function () {
        if (this.animalAry.length < this.maxCount) {
            return false;
        }
        var last = this.getLastTypeAnimal();
        var lastType = last.animalType;
        for (var i = this.animalAry.length - 2; i >= 0; i--) {
            var animal = this.animalAry[i];
            if (lastType != animal.animalType) {
                return false;
            }
        }
        return true;
    };
    level_bunchAnimalGroup.prototype.getMoveAnimals = function () {
        var animals = [];
        if (this.animalAry.length > 0) {
            var lastAnimal = this.getLastTypeAnimal();
            for (var i = this.animalAry.length - 1; i >= 0; i--) {
                var animal = this.animalAry[i];
                if (animal.animalType != lastAnimal.animalType) {
                    break;
                }
                else {
                    animals.push(animal);
                }
            }
        }
        return animals;
    };
    level_bunchAnimalGroup.prototype.getCanAddAnimalCount = function () {
        return this.maxCount - this.animalAry.length;
    };
    level_bunchAnimalGroup.prototype.setHintLb = function (str) {
        var _this = this;
        cc.Tween.stopAllByTarget(this.showNode);
        this.hintLb.string = str;
        this.hintNode.active = true;
        cc.tween(this.showNode).delay(2).call(function () {
            _this.hideHint();
        }).start();
    };
    level_bunchAnimalGroup.prototype.hideHint = function () {
        this.hintNode.active = false;
    };
    __decorate([
        property({ type: cc.Node, tooltip: "显示节点" })
    ], level_bunchAnimalGroup.prototype, "showNode", void 0);
    __decorate([
        property({ type: cc.Node, tooltip: "提示节点" })
    ], level_bunchAnimalGroup.prototype, "hintNode", void 0);
    __decorate([
        property({ type: cc.Label, tooltip: "提示文本节点" })
    ], level_bunchAnimalGroup.prototype, "hintLb", void 0);
    __decorate([
        property({ type: cc.Label })
    ], level_bunchAnimalGroup.prototype, "lb", void 0);
    level_bunchAnimalGroup = __decorate([
        ccclass
    ], level_bunchAnimalGroup);
    return level_bunchAnimalGroup;
}(cc.Component));
exports.default = level_bunchAnimalGroup;

cc._RF.pop();